<?php

/**
 * Usuario form base class.
 *
 * @method Usuario getObject() Returns the current form's model object
 *
 * @package    toyomotor
 * @subpackage form
 * @author     Ing. Roberto Hernández De La Luz at Netosfera
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUsuarioForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_usuario'   => new sfWidgetFormInputHidden(),
      'nombre'       => new sfWidgetFormInputText(),
      'apellido'     => new sfWidgetFormInputText(),
      'rif'          => new sfWidgetFormInputText(),
      'password'     => new sfWidgetFormInputText(),
      'email'        => new sfWidgetFormInputText(),
      'celular1'     => new sfWidgetFormInputText(),
      'telefono1'    => new sfWidgetFormInputText(),
      'Ciudad'       => new sfWidgetFormInputText(),
      'Zona'         => new sfWidgetFormInputText(),
      'recibir_info' => new sfWidgetFormInputCheckbox(),
      'perfil'       => new sfWidgetFormInputText(),
      'created_at'   => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id_usuario'   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_usuario')), 'empty_value' => $this->getObject()->get('id_usuario'), 'required' => false)),
      'nombre'       => new sfValidatorString(array('max_length' => 50)),
      'apellido'     => new sfValidatorString(array('max_length' => 50)),
      'rif'          => new sfValidatorString(array('max_length' => 50)),
      'password'     => new sfValidatorString(array('max_length' => 50)),
      'email'        => new sfValidatorEmail(array('max_length' => 80)),
      'celular1'     => new sfValidatorString(array('max_length' => 15)),
      'telefono1'    => new sfValidatorString(array('max_length' => 15, 'required' => false)),
      'Ciudad'       => new sfValidatorString(array('max_length' => 50)),
      'Zona'         => new sfValidatorString(array('max_length' => 50)),
      'recibir_info' => new sfValidatorBoolean(array('required' => false)),
      'perfil'       => new sfValidatorInteger(),
      'created_at'   => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => array('email')))
    );

    $this->widgetSchema->setNameFormat('usuario[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Usuario';
  }

}
